import React, { FC, ReactElement } from 'react';
import { Select, SelectProps, Col, Form } from 'antd';
import { getRulesConfig, commonInterface } from '@C/base/SFields/constant';
import './index.less';

// interface IProps extends commonInterface{
//   // 表单最大值，默认最大 32 位
//   maxLength: string|number;
// }

const defaultOptions = [
  { label: 'A', value: 'A', },
  { label: 'B', value: 'B', disabled: true },
  { label: 'C', value: 'C', },
];

const Index: FC<Partial<commonInterface> & Partial<SelectProps>> = (props): ReactElement => {
  const { name, label = '下拉选择器', span = 8, required = false, options, ruleIcon, formItemConfig, ...selectProps } = props;

  return (
    <Col span={span}>
      <div className="base-component-super-fields-common">
        <Form.Item
          label={label}
          name={name}
          rules={getRulesConfig(required, label, ruleIcon, `请选择${label}`)}
          {...formItemConfig}
        >
          <Select
            showSearch
            placeholder="请选择..."
            options={options || defaultOptions}
            {...selectProps}
          />
        </Form.Item>
      </div>
    </Col>
  );
};

export default Index;
